package com.cinematicketscaning.app.dialog;

import android.view.View;
import com.cinematicketscaning.app.R;
import com.cinematicketscaning.app.databinding.DialogDatepickerBinding;
import com.cinematicketscaning.app.utils.Utils;

public class DatePickerDialog extends BottomDialogFragment<DialogDatepickerBinding> {
    private DateCallback callback;
    @Override
    protected int setLayout() {
        return R.layout.dialog_datepicker;
    }

    @Override
    protected void initView(final DialogDatepickerBinding binding) {
        Utils.INSTANCE.setDatePickerDividerColor(binding.datePicker);
        binding.tvConfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (callback != null) {
                    callback.callback(binding.datePicker.getYear() + "" + Utils.INSTANCE.getFormatMonth(binding.datePicker.getMonth() + 1) + "" + Utils.INSTANCE.getFormatDay(binding.datePicker.getDayOfMonth()));
                }
                dismiss();
            }
        });
    }

    interface DateCallback {
        void callback(String date);
    }

    public DateCallback getCallback() {
        return callback;
    }

    public void setCallback(DateCallback callback) {
        this.callback = callback;
    }
}
